%%%-------------------------------------------------------------------
%%% File    : yaws_hello.erl
%%% Author  : Filippo Pacini <pacini@sgconsulting.it>
%%% Description : Yaws Hello world example
%%%
%%% Created : 18 Nov 2007 by Filippo Pacini <pacini@sgconsulting.it>
%%%-------------------------------------------------------------------
-module(yaws_hello).

%% API
-export([out/1,
         handle_req/2]).

%%====================================================================
%% API
%%====================================================================
out(Arg) ->
    M = ewgi_yaws:new(fun ?MODULE:handle_req/1),
    M:run(Arg).

handle_req(Ctx) ->
    error_logger:info_report(Ctx),
    {ok, C} = sgte:compile("
<html>
<head><title>Hello world</title></head>
<body>
<h1>Hello world !!!!</h1>
<form name='frmPost' method='POST' action='hello'>
<label>aaa</label><input type='text' name='aaa' value='bbb'><br>
<input type='submit' name='send' value='doPost'>
</form>
</body>
</html>"),
    Body = sgte:render(C, []),
    ewgi_api:set_response(#ewgi_response{status={200, "OK"}, headers=[], message_body=Body}, Ctx).

%%====================================================================
%% Internal functions
%%====================================================================
